# import datetime
# time_board = "{0:%Y-%m-%d %H:%M:%S/}".format(datetime.datetime.now())
# print(time_board)




'''下面是绘制结果的代码'''
import pickle
import matplotlib.pyplot as plt

f = open(r".\CUP_results\CUP_velocity_Swimmer-v3_hyperparams_seed_1.pkl",'rb')
hyperparams = pickle.load(f)
print(hyperparams)
f = open(r".\CUP_results\CUP_velocity_Swimmer-v3_log_data_seed_1.pkl",'rb')
log_data = pickle.load(f)
# print(log_data)
# print(hyperparams['env_id'])
# hhhhhhhhh



def plot_result(result_data, plot_what, hyperparams, name_method):
    plt.figure()
    plt.plot(list(range(len(result_data))), result_data)
    # plt.plot(list(range(len(result_data))), result_data, label=f'{name_method} (non-smoothed)')
    # result_data_mv = rl_utils.moving_average(result_data, 100)
    # result_data_mv = rl_utils.smooth(result_data, weight=0.9)
    # plt.plot(list(range(len(result_data_mv))), result_data_mv, label=f'{name_method} (smoothed)')
    plt.xlabel('Number of Main Iterations')
    plt.ylabel(plot_what)
    env_id = hyperparams['env_id']
    plt.title(f'{name_method} on {env_id} (Training)')
    plt.legend(loc='best')
    plt.grid()
    plt.show()


plot_what = 'AvgR'
plot_result(log_data[plot_what], plot_what, hyperparams, hyperparams["algo"])
plot_what = 'AvgC'
plot_result(log_data[plot_what], plot_what, hyperparams, hyperparams["algo"])